<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
<!-- designer-manual.qdoc -->
  <title>伙伴编辑模式 | Qt Designer 手册</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td ><a href="../qtdoc/index.html">Qt 5.14</a></td><td ><a href="qtdesigner-manual.html">Qt Designer 手册</a></td><td >伙伴编辑模式</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtdesigner-manual.html">Qt 5.14.2 参考文档</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
  <link rel="prev" href="designer-connection-mode.html" />
  <link rel="next" href="designer-tab-order.html" />
<p class="naviNextPrevious headerNavi">
<a class="prevPage" href="designer-connection-mode.html">信号和槽编辑模式</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="designer-tab-order.html">标签的顺序编辑模式</a>
</p><p/>
<div class="sidebar">
<div class="toc">
<h3><a name="toc">目录</a></h3>
<ul>
<li class="level1"><a href="#linking-labels-to-buddy-widgets">链接标签到伙伴小部件</a></li>
<li class="level1"><a href="#removing-buddy-connections">删除伙伴连接</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">伙伴编辑模式</h1>
<span class="subtitle"></span>
<!-- $$$designer-buddy-mode.html-description -->
<div class="descr"> <a name="details"></a>
<p class="centerAlign"><img src="images/designer-buddy-mode.png" alt="" /></p><p>Qt最有用的基本特性之一是对伙伴小部件的支持。当用户键入标签的快捷键组合时，伙伴小部件代表 <a href="../qtwidgets/qlabel.html">QLabel</a> 接受输入焦点。伙伴概念也被用于 Qt 的 <a href="../qtwidgets/model-view-programming.html">模型/视图（model/view）</a>框架中。</p>
<a name="linking-labels-to-buddy-widgets"></a>
<h2 id="linking-labels-to-buddy-widgets">链接标签到伙伴小部件</h2>
<p>要进入伙伴编辑模式，打开 <b>Edit</b> 菜单并选择 <b>编辑伙伴（Edit Buddies）</b>。此模式以类似于 <a href="designer-connection-mode.html">信号槽编辑模式</a> 的方式在窗体上显示小部件，但在此模式中，连接必须从标签小部件开始。理想情况下，应该将提供快捷方式的每个label小部件与合适的输入小部件(比如 <a href="../qtwidgets/qlineedit.html">QLineEdit</a> )连接起来。</p>
<a name="makingbuddies"></a><div class="table"><table class="generic">
 <tr valign="top" class="odd"><td ><img src="images/designer-buddy-making.png" alt="" /></td><td ><b>建立伙伴</b><p>要为标签定义伙伴小部件，请单击该标签，将连接拖动到窗体上的另一个小部件，然后释放鼠标按钮。所示的连接指示如何将输入焦点传递给伙伴小部件。您可以使用窗体预览来测试每个标签与其伙伴之间的连接。</p>
</td></tr>
</table></div>
<a name="removing-buddy-connections"></a>
<h2 id="removing-buddy-connections">删除伙伴连接</h2>
<p>每个标签只能定义一个伙伴小部件。要更改所使用的伙伴连接，必须在创建新伙伴连接之前删除任何现有的伙伴连接。</p>
<p>标签及其伙伴小部件之间的连接可以与信号和槽编辑模式中的信号-槽连接相同的方式删除:单击伙伴连接并按 <b>Delete</b> 键。此操作不对标签或其伙伴小部件进行修改。</p>
</div>
<!-- @@@designer-buddy-mode.html -->
<p class="naviNextPrevious footerNavi">
<a class="prevPage" href="designer-connection-mode.html">信号和槽编辑模式</a>
<span class="naviSeparator">  &#9702;  </span>
<a class="nextPage" href="designer-tab-order.html">标签的顺序编辑模式</a>
</p>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2020 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>
